package com.novoda.runbuddy;

import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.test.InstrumentationTestRunner;
import android.util.Log;

import com.novoda.runbuddy.util.DBUtil;

public class RunBuddyTestRunner extends InstrumentationTestRunner {
	private static final String	RUN_BUDDY_DB	= "runBuddyDB1.db";
	private DBUtil				dbUtil			= null;

	@Override
	public void onCreate(Bundle arg0) {
		// Recreate the DB
		Cursor cur = getTargetContext().getContentResolver().query(Uri.parse("content://com.novoda.runbuddy/routes"), null, null, null, null);
		if (cur!= null)
			cur.close();
		else Log.i("RunBuddy", "can not create DB");
		if (dbUtil == null) {
			dbUtil = new DBUtil(getTargetContext(), RUN_BUDDY_DB);
		}
		dbUtil.executeDB(R.raw.db_drop);
		dbUtil.executeDB(R.raw.db_create);
		dbUtil.getDatabase().close();
		super.onCreate(arg0);
	}
}
